/*!
 * \file symbol_table.h
 *
 * \brief Declarations for the SymbolTable and STE classes
 *        dealing with Sparse Constraints and their tokens
 *
 * \date Started: 6/8/2010
 * \date Last Modified: 10/1/2010
 * \authors Alan LaMielle
 * \authors Ian Craig
 * \authors Nicholas Jeannette
 *
 * Copyright (c) 2010, Colorado State University <br>
 * All rights reserved. <br>
 * See ../../COPYING for details. <br>
 */

#ifndef SYMBOL_TABLE_H
#define SYMBOL_TABLE_H

#include <iegenlib/iegenlib.h>

#include <map>
using std::map;
#include <utility>
using std::pair;
#include <string>
using std::string;
#include<set>
using std::set;
#include<list>
using std::list;
#include<vector>
using std::vector;

namespace iegenlib{

class SRVisitor;
class SymbolTable;

/*!
 * Symbol Type enumeration
 *
 * There are 4 types of constraints: variable tuples, existential variables,
 * symbolics, and uninterpreted function calls.
 *
 * This enumeration is a representation of these 2 symbols:
 * \li SYMBOLIC = 0
 * \li TUPLE = 1
 * \li EXISTENTIAL = 2
 * \li UFCALL = 3
 * \li CONST = 4
 */
enum SymType{ SYMBOLIC = 0 ,TUPLE = 1, EXISTENTIAL = 2, UFCALL = 3, CONST = 4 };

/*!
 *  \class ExpVec
 *
 *  \brief A class that represents an expression in vector form
 *
 *  This class represents expressions in vector form by placing the coefficents
 *  of the various parts of the expression into thier respective vectors
 */
class ExpVec{
public:
friend class iegenlib::SymbolTable;

  ExpVec(ExpVec const& ST);
  ExpVec& operator=(ExpVec const& ST);
  ~ExpVec();

  ExpVec copy_coeff(ExpVec const& other) const;

  /*!
   * Adds a value to the constant coefficent
   * @param addVal The value to be added;
   */
  inline void add_const(int addVal){const_coeff += addVal;}

  ///@return the list of symbolic constant coefficients
  inline const vector<int> get_symconst_coeffs() const
  { return symconst_coeffs; }

  ///@return the list of tuple variable coefficients
  inline const vector<int> get_tuplevars_coeffs() const
  { return tuplevars_coeffs; }

  ///@return the list of existential variable coefficients
  inline const vector<int> get_existvars_coeffs() const
  { return existvars_coeffs; }

  ///@return the list of uninterpreted function call coefficients
  inline const vector<int> get_ufcalls_coeffs() const
  { return ufcalls_coeffs; }

  ///@return the size of the symbolic constant coefficient list
  inline const int get_symconst_size() const
  { return symconst_coeffs.size(); }

  ///@return the size of the tuple variable coefficient list
  inline const int get_tuplevars_size() const
  { return tuplevars_coeffs.size(); }

  ///@return the size of the existential variable coefficient list
  inline const int get_existvars_size() const
  { return existvars_coeffs.size(); }

  ///@return the size of the uninterpreted function call coefficient list
  inline const int get_ufcalls_size() const
  { return ufcalls_coeffs.size(); }

  ///@return int The constant value
  inline const int get_const() const{return const_coeff;}

  inline void set_const(int i) {const_coeff = i;}

  /*!
   * A method to be used to set a specific coefficient in the expression vector
   * by using the type of value it is a coefficient to and the location in the
   * coefficient in the respective type vector
   * @param type The type of value the coefficient is representing
   * @param col The column location inside of the vector
   * @param coeff The value to set the specific variable/function/const's
                  coefficient to
   */
  void set_coeff(SymType type, int col, int coeff);

  ///@return int The coefficient of a specific variable
  int get_coeff(SymType type, int col) const;

  /*!
   * Operator +
   *
   * Adds two expression vectors together such that any value for each
   * coefficient is added together i.e. if two ExpVec's had the following for
   * their symbolic constant vector: 0 1 2, and then were added together, the
   * new symbolic constant vector would be 0 2 4
   * @param op1 The first operand in the addition expression
   * @param op2 The second operand in the addition expression
   * @return A new ExpVec representing the two operands added together
   */
  friend ExpVec operator+(const ExpVec& op1, const ExpVec& op2);

  /*!
   * Operator *
   *
   * Multiplies the expression vector by the given integer value
   *
   * @return the scaled expression vector
   */
  ExpVec operator*(int coeff);

  /*!
   * Operator <
   *
   * Used for other classes needing ExpVec's and are in a set (i.e. SREquality,
   * SRInequality)
   * Compares in the following order:
   * \li this.num_symconst < other.num_symconst
   * \li this.num_tuplevars < other.num_tuplevars
   * \li this.num_existvars < other.num_existvars
   * \li this.num_ufcalls < other.num_ufcalls
   *
   * @param op1 The ExpVec to compare this ExpVec to
   * @return Boolean value depicting whether this ExpVec is less than the other
   *         ExpVec
   */
  const bool operator<(const ExpVec& op1) const ;

  /*!
   * Operator ==
   *
   * Used for other classes needing ExpVec's and need to compare ExpVec's
   * against each other (i.e. SRConjunction)
   * Compares in the following order:
   * \li this.num_symconst == other.num_symconst
   * \li this.num_tuplevars == other.num_tuplevars
   * \li this.num_existvars == other.num_existvars
   * \li this.num_ufcalls == other.num_ufcalls
   *
   * @param other The ExpVec to compare this ExpVec to
   * @return boolean value depicting whether this ExpVec is equivalent to the
   *                 other ExpVec
   */
  const bool operator==(const ExpVec& other) const ;

  ///@return string representing all of the sizes of each vector
  string toString() const;

  ///@return string representing a constraint with all of the variables
  ///and coefficients
  string toString(SymbolTable*) const ;

  ///@return string with each vector labeled and all coefficients in place.
  string vectorStrings();

  /*!
   * Apply method used for traversing the symbol table tree
   * @param visitor Visitor that is traversing the tree
   */
  void apply(SRVisitor* visitor) const;

  /*!
   * Takes the expression vector and looks for the first nonzero value. If it is
   * negative, then go through the vectors and invert all nonzero values. This
   * is used to ensure that if we have two equalities that are equivalent, but
   * not equal, i.e. x = y and y = x, then we can figure out that they are equal
   * and discard one.
   *
   * WARNING: SHOULD ONLY EVER BE USED WITH SREQUALITY.
   */
  void normalizeEquality();

  /*!
   * Determine if any coefficients of the given type are non-zero.
   *
   * @param type the type of term to examine
   * @param pos output parameter, set to the position of the term if a non-zero
   *            is found
   * @param coeff output parameter, set to the value of the non-zero coefficient
   *              if one is found
   * @return true if any coefficients of the given type are non-zero, false otherwise.
   */
  bool any(SymType type,int& pos,int& coeff) const;

  /*!
   * Determine if any coefficients of the given type at the given position are
   * non-zero.
   *
   * @param type the type of term to examine
   * @param pos the position of the term to check for non-zero coefficients
   * @param sym_table the symbol table to use to recurse into UFCall parameters
   * @return true if any coefficients of the given type in the given position
   *         are non-zero, false otherwise.
   */
  bool any(SymType type,int pos,SymbolTable const*const sym_table=NULL) const;  

  /*!
   * Determine if any coefficients of the given type are non-zero.
   *
   * @param type the type of term to examine
   * @param pos output parameter, set to the position of the term if a non-zero
   *            is found
   * @param coeff output parameter, set to the value of the non-zero coefficient
   *              if one is found
   * @param sym_table the symbol table to use to recurse into UFCall parameters
   * @@return true if any coefficients of the given type are non-zero, false otherwise.
   */
  bool anyNesting(SymType type,int& pos,int& coeff, SymbolTable const*const 
  sym_table) const; 

  /*!
   * Replaces the existential at the given postiion with the given expression.
   *
   * @param sym_table the symbol table to use
   * @param exist_pos the position of the existential to replace
   * @param equal_exp the expression to replace the existential with
   * @return an ExpVec with the existential replaced
   */
  ExpVec replaceExistential(SymbolTable* sym_table,int exist_pos,
                            ExpVec equal_exp) const;

  /*!
   * @return true if there are no UFS terms in the expression, false otherwise
   */
  bool isAffine() const;

private:
  /*!
   * ExpVec Constructor
   *
   * @param num_symconst The number of SymConsts (symbolic constants) in the
                         expression
   * @param num_tuplevars The number of TupleVars (tuple variables) in the
                          expression
   * @param num_existvars The number of ExistVars (existential variables) in the
                          expression
   * @param num_ufcalls The number of UFCalls (uninterpreted function calls) in
                        the expression
   */
  ExpVec(int num_symconst, int num_tuplevars, int num_existvars,
         int num_ufcalls, int constant = 0);

  /*!
   * Helper method for normalizeEquality() that finds the first nonzero value
   * and checks to see if it is negative.
   * @param begin The beginning of a vector to look through
   * @param end The end of a vector to look through
   * @param negative Boolean representing whether or not the first value is
   *                 negative
   * @param first Boolean representing whether the first non-zero value was
   *              found
   */
  void normalizeHelperFindNegative(vector<int>::const_iterator begin,
                                   vector<int>::const_iterator end,
                                    bool* negative, bool* first);

  /*!
   * Helper method for normalizeEquality() that inverts the vectors
   * @param vec Vector to invert.
   */
  void normalizeHelperInverseArray(vector<int>* vec);

  string ufcallStringHelper(list<ExpVec> params, SymbolTable* ST) const ;

  vector<int> add_coeff_vecs(vector<int> vec1,vector<int> vec2) const;

  ///vector of TupleVar coefficents
  vector<int> tuplevars_coeffs;

  ///vector of ExistVar coefficents
  vector<int> existvars_coeffs;

  ///vector of SymConst coefficents
  vector<int> symconst_coeffs;

  ///vector of UFCall coefficents
  vector<int> ufcalls_coeffs;

  ///constant value in the expression
  int const_coeff;

};

/*!
 *  \class STE
 *
 *  \brief Base Symbol Table Entry class
 *
 *  All symbol table entry types inherit from this class. It holds a
 *  representative value for what type of symbol is being used, the name of the
 *  symbol, and the column position in the matrix
 */
class STE{
public:
  ///@return string Returns the identifier of this STE
  inline string getId(){ return id; }

  ///@return SymType Returns the type of symbol this entry represents
  inline SymType getType(){ return type; }

  ///@return int Returns the column location of the symbol in an ExpVec
  inline int getCol(){ return col; }

  /*!
   * Operator ==
   * @param other A different STE to compare this one to
   * @return bool Returns whether or not this STE is equivelant to the other STE
   */
  const bool operator==(const STE& other) const ;

  virtual string toString() const=0;

  virtual void apply(SRVisitor*)=0;

protected:

  /*!
   * STE Constructor
   *
   * Only usable by classes that inherit from STE. Automatically sets the
   * entry's id, type, and column
   *
   * @param id The id of the entry
   * @param type The symbol type of the entry
   * @param col The column of the entry
   */
  inline STE(string id, SymType type, int col): id(id), type(type), col(col){};

  virtual string toStringCommon(string type_string) const;

  ///The entry's id
  string id;
  ///The entry's symbol type
  SymType type;
  ///The entry's column
  int col;
};

/*!
 *  \class TupleVar
 *
 *  \brief Symbol Table Entry (STE) Class representing Tuple Variables
 */
class TupleVar: public STE{
public:
  /*!
   * TupleVar Constructor
   *
   * @param id The id of the TupleVar
   * @param col The column of the TupleVar
   * @param loc The location of the TupleVar in it's tuple list
   */
  inline TupleVar(string id, int col):STE(id,TUPLE,col){};

  string toString() const;

  /*!
   * Apply method used for traversing the symbol table tree
   * @param visitor Visitor that is traversing the tree
   */
  void apply(SRVisitor* visitor);

  ///@return true if the TupleVar is representing a constant, false otherwise
  inline bool isConst(){ if(id.size() == 0) return true; return false;}

private:
  ///Location of the TupleVar in the actual tuple list
  int location;
};

/*!
 *  \class ExistVar
 *
 *  \brief Symbol Table Entry (STE) Class representing Existential Variables
 */
class ExistVar: public STE{
public:
  /*!
   * ExistVar Constructor
   *
   * @param id The id of the ExistVar
   * @param col The column of the ExistVar
   */
  inline ExistVar(string id, int col):STE(id,EXISTENTIAL,col){};

  string toString() const;

  /*!
   * Apply method used for traversing the symbol table tree
   * @param visitor Visitor that is traversing the tree
   */
  void apply(SRVisitor* visitor);
};

/*!
 *  \class SymConst
 *
 *  \brief Symbol Table Entry (STE) Class representing Symbolic Constants
 */
class SymConst: public STE{
public:
  /*!
   * SymConst Constructor
   *
   * @param id The id of the SymConst
   * @param col The column of the SymConst
   */
  inline SymConst(string id, int col):STE(id,SYMBOLIC,col){};

  string toString() const;

  /*!
   * Apply method used for traversing the symbol table tree
   * @param visitor Visitor that is traversing the tree
   */
  void apply(SRVisitor* visitor);
};

/*!
 *  \class UFCall
 *
 *  \brief Symbol Table Entry (STE) Class representing Uninterpreted Function
 *         calls
 */
class UFCall: public STE{
public:
  /*!
   * UFCall Constructor
   *
   * @param name The name of the function
   * @param col The column of the UFCall
   * @param params A list of Expression Vectors representing the parameters
   */
  UFCall(string name, int col, list<ExpVec>* params);

  ///@return The list of parameters that are involved in this function
  inline const list<ExpVec> getParams() const { return paramIDs; }

  ///@return The start iterator of the list of parameters
  inline const list<ExpVec>::const_iterator getParamsBegin() const
  {return paramIDs.begin();}

  ///@return The end iterator of the list of parameters
  inline const list<ExpVec>::const_iterator getParamsEnd() const
  {return paramIDs.end();}

  string toString() const;

  /*!
   * Apply method used for traversing the symbol table tree
   * @param visitor Visitor that is traversing the tree
   */
  void apply(SRVisitor* visitor);

  /*!
   * Apply method used for traversing the symbol table tree
   * @param visitor Visitor that is traversing the tree
   */
  void applyParams(SRVisitor* visitor);

  /*!
   * Creates a string representation of the function that this UFCall represents
   * @param st SymbolTable involved with this function
   */
  string getFullFunc(SymbolTable* st);

  /*!
   * Calls any on each of the UFCall's arguments
   */
  bool any(SymType type,int pos,SymbolTable const*const sym_table) const;

  /*!
   * Calls anyNesting on each of the UFCall's arguments 
   * support nested UFC functions
   */
  bool anyNesting(SymType type,int& pos,int& coeff, SymbolTable const*const
  sym_table) const;

private:
  ///List of Expression Vectors representing the parameters
  list<ExpVec> paramIDs;
};

/*!
 * \class TupleType
 *
 * \brief Class representing values and variables in a tuple list
 *
 * This class is used to represent tuple values and variables. It contains a
 * name field if the tuple is a variable and a value field if the tuple is just
 * a constant value. It also contains a boolean representing if the Tuple is
 * a variable or constant.
 */
class TupleType{
public:
  /*!
   * Tuple type constructor for constants
   * @param val Constant value
   */
  inline TupleType(int val):cVal(val), name(""), constant(true){};

  /*!
   * Tuple type constructor for variables
   * @param id Name of the variable
   */
  inline TupleType(string id):cVal(0), name(id), constant(false){};

  ///@return Name of the variable, blank if a constant
  inline const string getName() const { return name; }

  inline void setName(string nName) { name = nName; }

  ///@return Constant value, 0 if a variable
  inline const int getValue() const { return cVal; }

  ///@return True if the TupleType is a constant, false if it's a variable
  inline const bool isConst() const { return constant; }

  ///@return True if the TupleType is a variable, false if it's a constant
  inline const bool isVar() const { return !(this->isConst()); }

  /*!
   * Apply method used for traversing the Set/Relation tree
   * @param visitor Visitor that is traversing the tree
   */
  void apply(SRVisitor* visitor) const ;

private:
  ///boolean representing whether the TupleType is constant or a variable
  bool constant;

  ///name of the variable (if a variable, blank otherwise)
  string name;

  ///value of the constant (if a constant, 0 otherwise)
  int cVal;
};

/*!
 * \class SymbolTable
 *
 * \brief A class that represents a symbol table for the SparseConstraints
 *        classes
 *
 * The symbol table class contains all the symbols (any variable in the tuple
 * list, any existential variable, all the predefined symbolics, and any
 * function call) that are involved with the Sparse Constraints classes.
 */
class SymbolTable{
public:
  /*!
   * Symbol Table Constructor
   *
   * The constructor will automatically create most of the symbol table entries
   * from the input sets.
   * @param tuplevars A set of variables with their location in their variable
                      tuple set to be added to the symbol table
   * @param symconsts A set of symbolic constants to be added to the symbol
                      table
   * @param exists    A set of existential variables to be added to the symbol
                      table.
   * @param funcCount The total number of function calls that is being made in
                      the set/relation
   * @param constvals The constant values present in the variable tuple set
                      which is used to properly traverse the symbol table
                      structure
   */
  SymbolTable(const set<string>* tuplevars,
              const set<string>* symconsts,
              const set<string>* exists,
              const int funcCount);

  /*!
    * Symbol Table Deep Copy Constructor
    *
    * @param Symbol Table the symbol table that is going to be copied
    */
  SymbolTable(const SymbolTable& ST);

  /*!
   * Symbol Table Destructor
   *
   * The destructor will deep destroy the maps within the symbol table. This
   * means that the union method MUST delete the keys that are moved
   */
  ~SymbolTable();

   /*!
    * Symbol Table operator=
    * Calls the copy constructor and returns a reference to a new Symbol Table
    * created by ST
    * @param ST the Symbol Table to be copied
    * @return a reference to the a new Symbol Table that is copied from ST
    */
  SymbolTable& operator=(const SymbolTable& ST);

  /*!
   * Looks up a symbol table entry by the name of the symbol. The name is
   * either a tuple variable, symbolic constant, or existential variable. If
   * the STE does not exist, an exception is raised.
   *
   * @param sym The name of the symbol
   * @return A pointer to the symbol table entry
   */
  STE* lookup(string sym) const;

  /*!
   * Looks up a function symbol table entry by the name of the function symbol
   * and a list of its parameters. If the STE does not exist, then a new STE is
   * created to represent the symbol. In this case, lookup wuill create a
   * function STE.
   * @param fname      The name of the function
   * @param paramIDs   A list of the parameters
   * @return           A pointer to the symbol table entry
   */
  UFCall* lookup(string fname, list<ExpVec> paramIDs);

  /*!
   * Looks up a symbol table entry by the type of symbol and its column number
   * @param type The type of the symbol
   * @param col The column of the symbol
   * @return A pointer to the symbol table entry
   */
  STE* lookup(SymType type, int col) const;

  TupleVar* lookup_tuple(int col) const;
  SymConst* lookup_symconst(int col) const;
  ExistVar* lookup_exist(int col) const;
  UFCall* lookup_ufcall(int col) const;

  ///Increments the number of uninterpreted function calls
  inline void incrNumUFCalls() {num_ufcalls++;}

  /*!
   * Returns an Expression vector using the numbers that the symbol table has
   * available to itself
   * @return A maximum size Expression Vector with all coefficients set to 0.
   */
  ExpVec constructExpVec() const;

  /*!
   * Returns an Expression vector using the numbers that the symbol table has
   * available to itself with the specified variable coefficient set.
   * @param var The variable coefficient to set.
   * @param int The coefficient value.
   * @return An expression vector with all the coefficients set to 0 except for
   *         the specified coefficient.
   */
  ExpVec constructExpVec(string var, int coeff);

  /*!
   * Returns an Expression vector using the numbers that the symbol table has
   * available to itself with the constant set to the value passed through.
   * @param const_coeff The value of the constant in the ExpVec.
   * @return An expression vector with all the coefficients set to 0 and the
   *         constant value set to the value that was passed in.
   */
  ExpVec constructExpVec(int const_coeff) const;

  /*!
   * Returns an Expression vector using the numbers that the symbol table has
   * available to itslef with the specified function name coefficient set.
   * @param fname The name of the function
   * @param params The list of the functions parameters in ExpVec form
   * @param coeff The value to set the coefficient to
   * @return An expression vector with all the coefficients set to 0 except for
   *         for the specified function coefficient set to the value passed in.
   */
  ExpVec constructExpVec(string fname, list<ExpVec> params, int coeff);

  ///@return string Returns the symbol table in string form
  string toString() const;

  /*!
   * Apply method used for traversing the symbol table tree
   * @param visitor Visitor that is traversing the tree
   */
  void apply(SRVisitor* visitor);

  /*!
   * Apply helper method used for traversing the symbol table tree
   * @param visitor Visitor that is traversing the tree
   */
  void applySTEs(SRVisitor* visitor);

  ///@return iterator to beginning of id list
  list<string>::const_iterator getIdBegin();

  ///@return iterator to end of id list
  list<string>::const_iterator getIdEnd();

  ///@return iterator to beginning of existential STEs
  list<STE*>::const_iterator existBegin();

  ///@return iterator to the end of existential STEs
  list<STE*>::const_iterator existEnd();

  ///@return iterator to beginning of existential names
  list<string>::const_iterator existNamesBegin();

  ///@return iterator to the end of existential names
  list<string>::const_iterator existNamesEnd();

  ///@return true if this symbol table contains the given existential, false
  ///otherwise
  bool containsExistential(string name);

  ///@return iterator to beginning of symbolic STEs
  list<STE*>::const_iterator symBegin();

  ///@return iterator to the end of symbolic STEs
  list<STE*>::const_iterator symEnd();

  ///@return iterator to beginning of symbolic names
  list<string>::const_iterator symNamesBegin();

  ///@return iterator to the end of symbolic names
  list<string>::const_iterator symNamesEnd();

  ///@return iterator to the beginning of the UFCalls
  list<UFCall*>::const_iterator ufcallsBegin();

  ///@return iterator to the end of the UFCalls
  list<UFCall*>::const_iterator ufcallsEnd();

  /*!
   * A helper function that iterates through the mTypeColToSTE map adding the
   * SymType of either existentals or symbolics to a list so the iterators for
   * symbolics or existentals can be used.
   * @param SymType the type we are searching the map for
   */
  void makeItList(SymType existsyms);

  /*!
   * A helper function that iterates through the mTypeColToSTE map adding the
   * id string of either existentals or symbolics to a list so the iterators for
   * symbolics or existentals can be used.
   * @param SymType the type we are searching the map for
   */
  void makeItNamesList(SymType existsyms);

  /*!
   * A helper function that iterates through the mTypeColToSTE map adding the
   * IDs to a list so the iterators for id can be used
   */
  void makeIdList();

  inline int numSTE() {return (num_tuplevars + num_existvars + num_symconsts + num_ufcalls);}

  ///@return A mapping of STE types to the number of each type
  const map<SymType, int> getTotals() const;

  /*!
   * Converts Expression Vectors from this symbol table to the new symbol table
   * given in the method.
   * @param oldEv The expression vector to be converted.
   * @param newST The new symbol table to convert this expression vector to
   * @param symbolMapping The mapping of symbols from this symbol table to the
   *                      new symbol table
   * @return a new expression vector that is the old expression vector
   *         represented with the new symbol table
   */
  ExpVec convertExpVec(ExpVec oldEV, SymbolTable* newST,
                       map<string,string>* symbolMapping);

  inline const int getNumFuncs() const { return num_ufcalls; }

  ///@return bool returns true if there are any existentials, false otherwise.
  inline const bool containsExistVars() const { if(num_existvars > 0){ return true; } return false; }

private:
  ///The number of tuple variables
  int num_tuplevars;

  ///The number of existential variables
  int num_existvars;

  ///The number of symbolic constants
  int num_symconsts;

  ///The number of uniterpreted function calls
  int num_ufcalls;

  ///Boolean to represent when incrNumUFCalls is allowed to be used
  bool doneIncr;

  ///The number of UFCs that have an STE
  int UFCcount;

  ///A mapping of symbol names to their respective Symbol Table Entry
  map<string,STE*> mSymToSTE;

  /*!
   * A mapping of symbol types and columns to their respective Symbol Table
   * Entry
   */
  map<pair<SymType, int>, STE*> mTypeColToSTE;

  /*!
   * A mapping of function names and their paramater list to their respective
   * Symbol Table Entry
   */
  map<pair<string, list<ExpVec> >, STE* > mNameListToSTE;

  ///A list of Symbol Table Entries for Existentials or Symbolics
  list<STE*> mItList;

  ///A list of IDs for Symbol Table Entries
  list<string> mIdList;

  ///A list of UFCalls for iteration
  list<UFCall*> mUFCallsList;

  ///@return iterator to beginning of mTypeColToSTE map
  inline map<pair<SymType, int>, STE*>::const_iterator mapBegin() const {
    return mTypeColToSTE.begin();
  }

  ///@return iterator to the end of mTypeColToSTE map
  inline map<pair<SymType, int>, STE*>::const_iterator mapEnd() const {
    return mTypeColToSTE.end();
  }

  /*!
   * A helper method for the converting of expression vectors from this symbol
   * table to a new symbol table
   * @param oldEv The expression vector to be converted.
   * @param newST The new symbol table to convert this expression vector to
   * @param symbolMapping The mapping of symbols from this symbol table to the
   *                      new symbol table
   * @param type The type of symbol table entry that is expected next
   * @param size The size of the vector that we are looking through in the old
                 expression vector
   * @param retval A pointer to the expression vector that will be returned
                   in the convertExpMethod
   */
  void convertExpVecHelper(ExpVec oldEV, SymbolTable* newST,
                           map<string,string>* symbolMapping, SymType type,
                           int size, ExpVec* retval);
};

}//end namespace iegenlib

#endif
